package com.fs.util;

public class StudentUtil {
    public static int getStugrade(int sid)
    {
        // 将int转换为String
        String numberStr = String.valueOf(sid);

        // 获取前两位作为年级
        int grade = Integer.parseInt(numberStr.substring(0, 2));

        return grade;
    }
    public static int getClassname(int sid)
    {
        // 将int转换为String
        String numberStr = String.valueOf(sid);

        int classname=0;
        if (numberStr.length() >= 3) {
            classname = Character.getNumericValue(numberStr.charAt(numberStr.length() - 3));

            System.out.println("班级: " + classname);
        } else {
            System.out.println("数字长度不足，无法获取倒数第三位。");
        }
        return classname;
    }

    public static void main(String[] args) {
        StudentUtil.getClassname(2100130214);
        StudentUtil.getStugrade(2100130214);
    }
}
